package com.vitabuybuy.tv.dialog

import android.content.Context
import android.view.View
import android.view.animation.Animation
import android.widget.TextView
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.dto.AddressListDto
import razerdp.basepopup.BasePopupWindow
import razerdp.util.animation.AnimationHelper
import razerdp.util.animation.ScaleConfig

/**
 * 删除弹出框
 */
class DeletePopup(
    context: Context,
    private var onConfirm: () -> Unit
) : BasePopupWindow(context) {
    private lateinit var tvDelete: TextView

    override fun onCreateContentView(): View {
        return createPopupById(R.layout.popup_delete)
    }

    override fun onViewCreated(contentView: View) {
        super.onViewCreated(contentView)
        tvDelete = findViewById(R.id.tvDelete)
        setViewClickListener(View.OnClickListener {
            onConfirm.invoke()
            dismiss()
        }, tvDelete)
    }

    override fun onCreateShowAnimation(): Animation {
        return AnimationHelper.asAnimation()
            .withScale(ScaleConfig.TOP_TO_BOTTOM)
            .withScale(ScaleConfig.RIGHT_TO_LEFT)
            .toShow()
    }

    override fun onCreateDismissAnimation(): Animation {
        return AnimationHelper.asAnimation()
            .withScale(ScaleConfig.BOTTOM_TO_TOP)
            .withScale(ScaleConfig.LEFT_TO_RIGHT)
            .toDismiss()
    }
}